<ol<?= !empty($id) ? " id=\"{$id}\"" : ''  ?><?= !empty($class) ? " class=\"{$class}\"" : ''  ?>>
<? if ($cur_page > 1): ?>
	<li><a href="<?= $page_url.($cur_page-1).(isset($hash)?"#{$hash}":'') ?>"><?= $label_previous ?></a></li>
<? elseif (!empty($always_show_labels) && ($last_page > 1)): ?>
	<li<?= !empty($class_disabled) ? " class=\"{$class_disabled}\"" : ' class="disabled"' ?>><?= $label_previous ?></li>
<? endif; ?>
<? for($start = 1, $stop = min(7, $last_page), $idx = $start; $idx <= $stop; ++$idx): ?>
	<li<?= $idx === $cur_page ? (!empty($class_selected) ? " class=\"{$class_selected}\"" : ' class="selected"') : '' ?>><a href="<?= $page_url.$idx.(isset($hash)?"#{$hash}":'') ?>"><?= $idx ?></a></li>
<? endfor; ?>
<? if ($cur_page > ($last_page - 5)): ?>
	<? if (($start = max($stop+1, intval($last_page/2))) > $stop+1): ?>
	<li>...</li>
	<? endif; ?>
	<? for($stop = min($start+4, $last_page), $idx = $start; $idx <= $stop; ++$idx): ?>
	<li<?= $idx === $cur_page ? (!empty($class_selected) ? " class=\"{$class_selected}\"" : ' class="selected"') : '' ?>><a href="<?= $page_url.$idx.(isset($hash)?"#{$hash}":'') ?>"><?= $idx ?></a></li>
	<? endfor; ?>
<? endif; ?>
<? if (($start = max($stop+1, ($cur_page > ($last_page - 5)) ? $last_page-4 : $cur_page-2)) > $stop+1): ?>
	<li>...</li>
<? endif; ?>
<? for($stop = min(max($stop+5, $cur_page+2), $last_page), $idx = $start; $idx <= $stop; ++$idx): ?>
	<li<?= $idx === $cur_page ? (!empty($class_selected) ? " class=\"{$class_selected}\"" : ' class="selected"') : '' ?>><a href="<?= $page_url.$idx.(isset($hash)?"#{$hash}":'') ?>"><?= $idx ?></a></li>
<? endfor; ?>
<? if (($start = max($stop+1, $last_page-4)) > $stop+1): ?>
	<li>...</li>
<? endif; ?>
<? for($stop = $last_page, $idx = $start; $idx <= $stop; ++$idx): ?>
	<li<?= $idx === $cur_page ? (!empty($class_selected) ? " class=\"{$class_selected}\"" : ' class="selected"') : '' ?>><a href="<?= $page_url.$idx.(isset($hash)?"#{$hash}":'') ?>"><?= $idx ?></a></li>
<? endfor; ?>
<? if ($cur_page < $last_page): ?>
	<li><a href="<?= $page_url.($cur_page+1).(isset($hash)?"#{$hash}":'') ?>"><?= $label_next ?></a></li>
<? elseif (!empty($always_show_labels) && ($last_page > 1)): ?>
	<li<?= !empty($class_disabled) ? " class=\"{$class_disabled}\"" : ' class="disabled"' ?>><?= $label_next ?></li>
<? endif; ?>
</ol>
